<form action="?act=6" name="frmxlEdit" method="post">
<table width="100%" class="XuLy" >

<?php
	include("../lib/DataProvider.php");
	if(isset($_GET['sk']))
	{
		$sk=$_GET['sk'];
		switch ($sk)
		{
		case 1:
				?>
				<tr>
					<td colspan="2" class="center">Thêm Seller</td>
				</tr>
				<tr>
					<td class="canphai">Tên ĐN:</td>
					<td><input name="txtTenDangNhap" type="text" id="txtTenDangNhap" size="30"></td>
				</tr>
				<tr>
					<td class="canphai">Mật Khẩu:</td>
					<td><input name="txtMatKhau" type="password" id="txtMatKhau" size="30"></td>
				</tr>
				<tr>
					<td class="canphai">Email:</td>
					<td><input name="txtEmail" type="text" id="txtEmail" size="30"></td>
				</tr>
				<tr>
					<td></td>
					<td >
						<input type="submit" name="btnThem" id="btnThem" value="Thêm">
						<input type="reset" name="btnReset" value="Làm mới">
						<input type="button" name="btnHuy" value="Huỷ bỏ" onclick="HuyEdit()">
					</td>
				</tr>
				
			<?php 
			break;
		case 2:
			if(isset($_GET['ID']))
			{
				$MaND=$_GET['ID'];
				$ds=DataProvider::ExecuteQuery("select nd.TENDANGNHAP,nd.MATKHAU,nd.MALND,lnd.TENLND, nd.EMAIL, lnd.ROLE, nd.KICHHOAT, nd.BIXOA from nguoidung nd, loainguoidung lnd where nd.MALND=lnd.MALND and nd.MAND='".$MaND."'");
				?>
				<tr>
					<td colspan="2" class="center">Sửa thông tin tài khoản</td>
				</tr>
				<?php 
				while($row = mysql_fetch_array($ds,MYSQL_ASSOC))
				{?>
				<tr>
					<td class="canphai">Mã ND:</td>
					<td><?php echo $MaND;?></td>
					<input type="hidden" name="txtMaND" id="txtMaND" value="<?php echo $MaND;?>">
				</tr>
				<tr>
					<td class="canphai">Tên ĐN:</td>
					<td><input type="text" name="txtTenDangNhap" id="txtTenDangNhap" value="<?php echo $row['TENDANGNHAP'];?>"></td>
				</tr>
				<tr>
					<td class="canphai">Mật Khẩu:</td>
					<td><input type="password" name="txtMatKhau" id="txtMatKhau" value="<?php echo $row['TENDANGNHAP'];?>"></td>
				</tr>
				<tr>
					<td class="canphai">Mã LND:</td>
					<td><input type="text" name="txtMaLND" id="txtMaLND" value="<?php echo $row['MALND'];?>">(S:Seller,B:Buyer,A:Admin)</td>
				</tr>
				<tr>
					<td class="canphai">Email:</td>
					<td><input type="text" name="txtEmail" id="txtEmail" value="<?php echo $row['EMAIL'];?>"></td>
				</tr>.
				<tr>
					<td></td>
					<td><input type="checkbox" name="cbKichHoat" id="cbKichHoat" 
					<?php if($row['KICHHOAT']==1) echo "checked='checked'";?>>Kích hoạt</td>
				</tr>
				<tr>
					<td></td>
					<td><input type="checkbox" name="cbBiXoa" id="cbBiXoa" 
					<?php if($row['BIXOA']==1) echo "checked='checked'";?>>Bị xoá</td>
				</tr>
				<tr>
					<td></td>
					<td>
						<input type="submit" name="btnCapNhat" id="txtCapNhat" value="Cập nhật">
						<input type="button" name="btnHuyBo" value="Huỷ bỏ" onClick="HuyEdit()">
					</td>
				</tr>
				<tr>
				<?php }
			}
			break;
		case 3:
			if(isset($_GET['ID']))
			{
				$MaND=$_GET['ID'];
				$ds1=DataProvider::ExecuteQuery("select * from dondathang where MAND='".$MaND."'");
				$ds2=DataProvider::ExecuteQuery("select * from sanpham where MAND='".$MaND."'");
				if(mysql_num_rows($ds1)>0 || mysql_num_rows($ds2)>0)
				{
					$update=DataProvider::ExecuteQuery("update nguoidung set BIXOA=1 where MAND='".$MaND."'");
					
					echo '<div class="center"><b>Người dùng này đã thực hiện chức năng giao dịch! Chúng ta sẽ dánh dấu xoá.</b></div>';
					?>
						<head>
						<meta http-equiv="refresh" content="2; url=?act=2" />
						</head>
					<?php
				}
				else{
					$delete1=DataProvider::ExecuteQuery("delete from diachi where MADIACHI='".$MaND."'");
					$delete2=DataProvider::ExecuteQuery("delete from hoso where MAHS='".$MaND."'");
					
					$delete3=DataProvider::ExecuteQuery("delete from nguoidung where MAND='".$MaND."'");
					echo '<div class="center"><b>Xoá thành công!</b></div>';
					?>
						<head>
						<meta http-equiv="refresh" content="2; url=?act=2" />
						</head>
					<?php
				} 
			}
			break;
		}
	}else{
		echo '<script type = "text/javascript">';
		echo 'location = "?act=2";';
		echo '</script>';
	}
?>
</table>
</form>